package com.android.memoprendiz.controller;

import java.util.Vector;

import com.android.memoprendiz.model.Configuration;
import com.android.memoprendiz.model.ConfigurationsDAO;
import com.android.memoprendiz.model.Ranking;
import com.android.memoprendiz.model.RankingDAO;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class RankingActivity extends ListActivity {
	private Vector<String> lista = new Vector <String>();
	private ArrayAdapter<String> handler;
	
    public void onResume(){
    	super.onResume();
        
        ConfigurationsDAO CD = new ConfigurationsDAO(this);
        Configuration config = CD.getConfiguration();
        int id = this.getResources().getIdentifier(config.getCaminhoEstilo(), "style",this.getPackageName());
        this.setTheme(id);
    }
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        ConfigurationsDAO CD = new ConfigurationsDAO(this);
        Configuration config = CD.getConfiguration();
        int id = this.getResources().getIdentifier(config.getCaminhoEstilo(), "style",this.getPackageName());
        this.setTheme(id);
        
		handler = new ArrayAdapter <String> (this, android.R.layout.simple_list_item_1, lista);
        geraLista();

        setListAdapter(handler);
    }
	
	public void geraLista() {
		RankingDAO PD = new RankingDAO(this);
		Vector<Ranking> rank = PD.getRanking(10);
		
		for(Ranking pt : rank){
			lista.add(pt.getPlayerName()+ " - " + pt.getPunctuation());
		}
	}
}